import React from "react";
import Icon from 'react-native-vector-icons/AntDesign';
import {
    Text,
    View,
    TouchableNativeFeedback
} from 'react-native';
export default class Selector extends React.Component {
    render() {
        return (
            <View>
                {
                    this.props.data.map((o, index) => (
                        <TouchableNativeFeedback key={index}
                            onPress={() => {
                                this.props.press(index, o)
                            }}
                            background={TouchableNativeFeedback.SelectableBackground()}>
                            <View key={index} style={{
                                backgroundColor: 'white',
                                flexDirection: "row",
                                justifyContent: 'flex-start',
                                alignItems: 'center',
                                padding: 8
                            }}>
                                <Text>{o.label}</Text>
                                {this.props.index === index ? <Icon name="check" size={16} /> : undefined}
                            </View>

                        </TouchableNativeFeedback>
                    ))
                }
            </View>
        )
    }
}